package com.itheima.web.controller;

import com.itheima.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    @Autowired
    protected HttpSession session;

    /**
     * 从域中获取登陆的用户信息
     * @return loginUser
     */
    protected User getLoginUser() {

        return (User) session.getAttribute("loginUser");
    }
    /**
     * 获取登陆用户所属企业id
     */
    protected String getLoginCompanyId(){
        return getLoginUser().getCompanyId();
    }

    /**
     * 获取登陆用户所属企业名称
     */
    protected String getLoginCompanyName(){
        return getLoginUser().getCompanyName();
    }

}
